package com.esri.core.internal.tasks.e.a;

import com.esri.core.geometry.Envelope;
import com.esri.core.geometry.SpatialReference;
import java.util.ArrayList;
import java.util.List;
import java.util.Stack;
import org.xml.sax.Attributes;

/* loaded from: classes.dex */
public class h {
    List<h> g;
    private Stack<String> m = new Stack<>();
    private StringBuilder n = null;
    String a = null;
    String b = null;
    Envelope c = null;
    SpatialReference d = null;
    String e = null;
    String f = null;
    private List<String> o = new ArrayList();
    double h = Double.NaN;
    double i = Double.NaN;
    protected List<g> j = null;
    protected g k = null;
    protected g l = null;

    /* JADX INFO: Access modifiers changed from: package-private */
    public void a(h hVar) {
        if (this.g == null) {
            this.g = new ArrayList();
        }
        this.g.add(hVar);
    }

    void a(double d) {
        this.i = d;
    }

    void b(double d) {
        this.h = d;
    }

    public List<String> a() {
        return this.o;
    }

    public void a(String str) {
        this.a = str;
    }

    public String b() {
        return this.a;
    }

    public String c() {
        return this.b;
    }

    public String d() {
        return this.e;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public void a(Envelope envelope) {
        this.c = envelope;
    }

    public Envelope e() {
        return this.c;
    }

    /* JADX INFO: Access modifiers changed from: package-private */
    public void a(SpatialReference spatialReference) {
        this.d = spatialReference;
    }

    public SpatialReference f() {
        return this.d;
    }

    public void b(String str) {
        this.b = str;
    }

    public void c(String str) {
        this.e = str;
    }

    void d(String str) {
        this.o.add(str);
    }

    void a(g gVar) {
        if (this.j == null) {
            this.j = new ArrayList();
        }
        this.j.add(gVar);
    }

    void e(String str) {
        this.f = str;
    }

    void b(g gVar) {
        this.l = gVar;
    }

    public List<g> g() {
        return this.j;
    }

    public g h() {
        return this.k;
    }

    public g i() {
        return this.l;
    }

    void c(g gVar) {
        this.k = gVar;
    }

    public void a(String str, Attributes attributes) {
        this.m.push(str);
        this.n = new StringBuilder();
        if ("EX_GeographicBoundingBox".equals(str)) {
            g gVar = new g();
            this.l = gVar;
            gVar.a(new Envelope());
        } else if ("LatLonBoundingBox".equals(str)) {
            b(attributes);
        } else if ("BoundingBox".equals(str)) {
            a(attributes);
        } else if ("OnlineResource".equals(str)) {
            c(attributes);
        }
    }

    public void f(String str) {
        String pop = this.m.pop();
        if (pop.equals("Name")) {
            o(this.n.toString().trim());
        } else if (pop.equals("Title")) {
            p(this.n.toString());
        } else if (pop.equals("Abstract")) {
            q(this.n.toString());
        } else if (pop.equals("westBoundLongitude")) {
            g(this.n.toString());
        } else if (pop.equals("eastBoundLongitude")) {
            h(this.n.toString());
        } else if (pop.equals("southBoundLatitude")) {
            i(this.n.toString());
        } else if (pop.equals("northBoundLatitude")) {
            j(this.n.toString());
        } else if (pop.equals("CRS")) {
            k(this.n.toString());
        } else if (pop.equals("SRS")) {
            l(this.n.toString());
        } else if (pop.equals("MinScaleDenominator")) {
            m(this.n.toString());
        } else if (pop.equals("MaxScaleDenominator")) {
            n(this.n.toString());
        }
        this.n = null;
    }

    public void a(char[] cArr, int i, int i2) {
        StringBuilder sb;
        String str = new String(cArr, i, i2);
        if (this.m.isEmpty() || (sb = this.n) == null) {
            return;
        }
        sb.append(str);
    }

    private void a(Attributes attributes) {
        String[] a = com.esri.core.internal.tasks.e.a.a(attributes, "SRS", "CRS", "minx", "miny", "maxx", "maxy");
        g gVar = new g();
        if (a[0] != null) {
            if (a[0].trim().equals("")) {
                return;
            }
            gVar.a(a[0]);
        }
        if (a[1] != null) {
            if (a[1].trim().equals("")) {
                return;
            }
            gVar.a(a[1]);
        }
        Envelope envelope = new Envelope();
        if (a[2] != null) {
            envelope.setXMin(Double.parseDouble(a[2]));
        }
        if (a[3] != null) {
            envelope.setYMin(Double.parseDouble(a[3]));
        }
        if (a[4] != null) {
            envelope.setXMax(Double.parseDouble(a[4]));
        }
        if (a[5] != null) {
            envelope.setYMax(Double.parseDouble(a[5]));
        }
        gVar.a(envelope);
        a(gVar);
    }

    private void b(Attributes attributes) {
        String[] a = com.esri.core.internal.tasks.e.a.a(attributes, "minx", "miny", "maxx", "maxy");
        g gVar = new g();
        Envelope envelope = new Envelope();
        if (a[0] != null) {
            envelope.setXMin(Double.parseDouble(a[0]));
        }
        if (a[1] != null) {
            envelope.setYMin(Double.parseDouble(a[1]));
        }
        if (a[2] != null) {
            envelope.setXMax(Double.parseDouble(a[2]));
        }
        if (a[3] != null) {
            envelope.setYMax(Double.parseDouble(a[3]));
        }
        gVar.a(envelope);
        c(gVar);
    }

    private void c(Attributes attributes) {
        if (this.m.size() == 3 && this.m.get(1).equals("LegendURL")) {
            this.e = attributes.getValue("xlink:href");
        }
    }

    private void k(String str) {
        if (str == null || str.length() <= 0 || this.m.size() != 0) {
            return;
        }
        d(str);
    }

    private void l(String str) {
        if (str == null || str.length() <= 0 || this.m.size() != 0) {
            return;
        }
        d(str);
    }

    private void m(String str) {
        if (str == null || str.length() <= 0 || !this.m.isEmpty()) {
            return;
        }
        b(Double.parseDouble(str));
    }

    private void n(String str) {
        if (str == null || str.length() <= 0 || this.m.size() != 0) {
            return;
        }
        a(Double.parseDouble(str));
    }

    private void o(String str) {
        if (str == null || str.length() <= 0 || this.m.size() != 0) {
            return;
        }
        a(str);
    }

    private void p(String str) {
        if (str == null || str.length() <= 0 || this.m.size() != 0) {
            return;
        }
        b(str);
    }

    private void q(String str) {
        if (str == null || str.length() <= 0 || this.m.size() != 0) {
            return;
        }
        e(str);
    }

    void g(String str) {
        if (str == null || str.length() <= 0) {
            return;
        }
        this.l.a().setXMin(Double.parseDouble(str));
    }

    void h(String str) {
        if (str == null || str.length() <= 0) {
            return;
        }
        this.l.a().setXMax(Double.parseDouble(str));
    }

    void i(String str) {
        if (str == null || str.length() <= 0) {
            return;
        }
        this.l.a().setYMin(Double.parseDouble(str));
    }

    void j(String str) {
        if (str == null || str.length() <= 0) {
            return;
        }
        this.l.a().setYMax(Double.parseDouble(str));
    }

    public List<h> j() {
        return this.g;
    }
}
